import Gobj from "./Gobj";
import GameWx from "../GameWx";
import Vobj from "./Vobj";

export default class VEnemy extends Vobj {
    txt = new Laya.Text;
    constructor() {
        super();
        this.pivotX = 20;
        this.pivotY = 20;
        this.txt.width = 40;
        this.txt.height = 40;
        this.txt.color = "#ffffff";
        this.txt.strokeColor = "#000000";
        this.txt.fontSize = 20;
        this.txt.stroke = 4;
        this.txt.align = "center";
        this.txt.valign = "middle";
        this.addChild(this.txt);

    }

   

    init(o: Gobj) {
        this.graphics.clear();
        if (o.pid == 1) { //1 == 房主
            //this.graphics.drawCircle(0, 0, 20, "#ff0000");
            this.graphics.drawRect(0, 0, 48,  48 , "#ff0000" );
        } else {
            //this.graphics.drawCircle(0, 0, 20, "#ffff00");
            this.graphics.drawRect(0, 0, 48,  48 , "#ffff00" );
        }    
        super.init(o);
        // if ((this.id % 2) != GameWx.I.my.role) { //1 == 房主
        //     this.x = this.sx = 665;
        //     this.y = this.sy = 80;
        // } else {
        //     this.x = this.sx = 85;
        //     this.y = this.sy = 1260;
        // }
    }

    efe(o: Gobj, lf: number ,fms:number) {
        var xx = Math.floor(o.x / 100);
        var yy = Math.floor(o.y / 100);
        if (this.isUP(o)) {
            this.x = this.sx - xx;
            this.y = this.sy + yy;
        } else {
            this.x = this.sx + xx;
            this.y = this.sy - yy;
            
        }
        this.txt.text = ""+Math.floor( o.hp / 100);
    }
}